package com.rcoming.activity;

import android.content.Intent;
import android.os.Bundle;
import android.widget.Button;
import android.widget.TextView;

import com.rcoming.R;
import com.rcoming.base.BaseActivity;
import com.rcoming.main.MainApplication;

import butterknife.BindView;
import butterknife.ButterKnife;
import cn.bingoogolapple.bgabanner.BGABanner;

public class GuideActivity extends BaseActivity {

    @BindView(R.id.banner_guide_background)
    BGABanner bannerGuideBackground;
    @BindView(R.id.banner_guide_foreground)
    BGABanner bannerGuideForeground;
    @BindView(R.id.tv_guide_skip)
    TextView tvGuideSkip;
    @BindView(R.id.btn_guide_enter)
    Button btnGuideEnter;

    // 每一页的控件集合
    private int[] views;
    // 每一页的提示文案
    private int[] images;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        initViews();
        setListener();
        initData();
    }

    private void initViews() {

        setContentView(R.layout.activity_guide);
        ButterKnife.bind(this);

    }

    private void initData() {

        views = new int[]{R.drawable.guide1, R.drawable.guide2, R.drawable.guide3, R.drawable.guide4};
        images = new int[]{R.drawable.power, R.drawable.fighting, R.drawable.future, R.drawable.rcoming};
        bannerGuideBackground.setData(views);
        bannerGuideForeground.setData(images);

    }

    private void setListener() {

        bannerGuideForeground.setEnterSkipViewIdAndDelegate(R.id.btn_guide_enter, R.id.tv_guide_skip, new BGABanner.GuideDelegate() {
            @Override
            public void onClickEnterOrSkip() {
                startActivity(new Intent(GuideActivity.this, SplashActivity.class));
                // 设置最新版本号
                MainApplication.getInstance().getSpUtil().setLeastVersionCode();
                finish();
            }
        });

    }

}
